An IF statement with an ELSEIF condition is the most complicated type of IF statement. If the first logical expression is true, the statement block after IF is executed until the first ELSEIF statement is reached. If the first logical expression is false, the first ELSEIF logical expression is evaluated. If the ELSEIF logical expression is true, the statement block from the ELSEIF to the next ELSEIF (or ELSE) is executed. If the ELSEIF statement is false, the next ELSEIF is evaluated. If all logical expressions are false, control passes to the ELSE block. If there is no ELSE block, control passes to the statement following the END keyword.
An ELSEIF statement is considered part of the same IF statement. Only one END keyword is needed to end an IF, ELSEIF, ELSE statement. IF statements can be nested inside other IF statements. A nested IF statement requires its own END keyword. A missing or mismatched keyword results in a runtime syntax error. Here is a sample IF statement with ELSEIF condition:
IF (@("FirstAmount") < 1000.00)
$FinalAmount = @("FirstAmount") * .05;
ELSEIF @("FirstAmount") < 5000.00
$FinalAmount = @("FirstAmount") * .03;
ELSEIF @("FirstAmount") < 10000.00
$FinalAmount = @("FirstAmount") * .02;
ELSE
$FinalAmount = @("FirstAmount") + 10.00;
END;
RETURN ($FinalAmount)
If the value of the section variable field FirstAmount is less than 1000.00 then the amount is multiplied by .05 and entered in the target variable $FinalAmount.
If the value of the section variable field FirstAmount is greater than or equal to 1000.00 but less than 5000.00 then the amount is multiplied by .03 and entered in the target variable $FinalAmount.
If the value of the section variable field FirstAmount is greater than or equal to 5000.00 but less than 10000.00 then the amount is multiplied by .02 and entered in the target variable $FinalAmount.
If the value of the section variable field FirstAmount is greater than or equal to 10000.00 then 10.00 is added to the amount and entered in the target variable $FinalAmount.
The value of the $FinalAmount field is then returned to the caller or section variable field.
© Copyright 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices